package com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler;

import com.iwhalecloud.bss.kite.cucc.service.attr.handler.AgreementMonthlyRentAttrHandler;
import com.iwhalecloud.bss.kite.cucc.service.util.CalculateDiscountsUtil;
import com.iwhalecloud.bss.kite.listener.handler.attr.annotation.AttrHandler;
import com.iwhalecloud.bss.kite.listener.handler.attr.impl.AbstractAttrLinkageHandler;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.scene.attr.OperateInstAttrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <Description> <br>
 *
 * @author chen.cheng110<br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2021年3月7日 <br>
 * @see com.iwhalecloud.bss.kite.cucc.service.attr.linkhandler <br>
 * @since R9.0<br>
 */
@Service
@AttrHandler(AgreementMonthlyRentAttrHandler.class)
public class AgreementMonthlyRentAttrLinkHandler extends AbstractAttrLinkageHandler<AttrData> {

    @Autowired
    OperateInstAttrService operateInstAttrService;

    @Autowired
    private IQuerySceneInstService querySceneInstService;

    /**
     * Description: <br>
     *
     * @param attr
     * @param inst
     * @param data <br>
     * @author chen.cheng110<br>
     * @taskId <br>
     */
    @Override
    public void handle(KiteAttr attr, KiteInst inst, AttrData data) {
        if (!"workOrder".equals(querySceneInstService.getExtParameterValue(data.getSceneInstId(), "initSource"))) {
            //根据标准月租和协议月租计算折扣
            CalculateDiscountsUtil.calculateDiscounts(data.getSceneInstId(), inst);
        }
    }

    @Override
    public void handleStyle(KiteAttr attr, KiteInst inst, AttrData data) {

    }

}
